<br>
<!--留言的展示-->
<div class="y1">
    <div>
        <% post.comments.forEach(function (comment){ %>
        <p>
            <a id="huifu"><%=  comment.name %></a>
            <span class="info"> 回复于: <%= comment.time %></span>
        </p>
        <p><%- comment.content %></p>
        <% })%>
        <!--添加留言的列表-->
        <% if (user) { %>
        <form method="post" action="/comment/<%= post.name %>/<%= post.time.minute %>/<%= post.title %>">
            回复人：<%= user.name %> <br>
            <input type="hidden" name="name" value="<%= user.name %>"/><br><br/>
            <textarea name="content" rows="5" cols="80"></textarea><br/>
            <input class="fabiao" type="submit" value="留言" />
        </form>
    </div>
    <div>
        <% } else { %>
        <form method="post">
            <div class="huifu">回复请先<a href="/login">登录</a>或<a href="/reg">注册</a></div><br/>
            <textarea name="content" rows="5" cols="80" id="tb"></textarea><br/><br/>
            <input class="fabiao" type="submit" value="留言" id="sb"/>
        </form>
        <% } %>
    </div>
</div>
<script>
    window.onload = function () {
        var textarea = document.querySelector('#tb');
        var button = document.querySelector('#sb');
        button.onclick = function (e) {
            e.preventDefault();
            location.href = '/login';
        }
        textarea.onfocus = function () {
            location.href = '/login';
        }
    }
</script>

